import { UPDATEPAGENEWEDUCATIONAINFORMATION } from '../types/pageneweducationainformation'
import { createAction } from 'redux-actions'
import { getUserArchiveInfoRequest } from '../../../../service/user-archive-controller'
import formatdata from '../../../../util/pagemethods/userArchInfo'

export const DOREQUESTNEWEDUCATIONAINFORMATION = createAction(
  UPDATEPAGENEWEDUCATIONAINFORMATION,
  payload => {
    return new Promise(resolve => {
      getUserArchiveInfoRequest({ ...payload }).then(({ data }) => {
        const { networkerror, entry, status, message } = data
        if (networkerror) {
          resolve({
            networkerror: true
          })
        } else {
          let Formatdata = new formatdata(entry || {}, '')
          let dataformat = Formatdata.getFormatData()
          resolve({
            networkerror: false,
            showEmpty: false,
            ...dataformat
          })
        }
      })
    })
  }
)
